<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<c:set var="disableBtn" value=""/>
<c:if test="${canAddOrUpdate ne true}">
	<c:set var="disableBtn" value=" disabled='true' "/>
</c:if>

<c:out value="${param.field_info}" escapeXml="false"/>

<form:form action="profile.pt" method="POST">
<input type="hidden" name="action_value" id="idActionValue" value="" />
<input type="hidden" name="selection_value" id="idSelectionValue" value="" />

<form:errors path="*" cssClass="error-message"/>

<div class="subheader">User Details:</div>

<table class="input-table">
	<tbody>
		<tr>
			<td width="20%">Role</td>
			<td><c:out value="${roleMap[command.roleId]}"/></td>
		</tr>
	
	<!-- Student Details Starts here -->
	<c:if test="${command.roleId == 'ROLE_STUDENT_FULL_ACCESS' || command.roleId == 'ROLE_STUDENT_VIEW_ONLY'}">
		<tr>
			<td>Student ID<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td>
				<form:input path="studentId" cssClass="input-text"/>
			</td>
		</tr>
		<tr>
			<td>Name<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td>
				<form:input path="name" cssClass="input-text"/>
			</td>
		</tr>
		<tr>
			<td>Registration No.<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td>
				<form:input path="registrationNo" cssClass="input-text"/>
			</td>
		</tr>
		<tr>
			<td>D.O.B</td>
			<td>
				<form:input path="dob" cssClass="input-text" readonly="true"/>
				&nbsp;
				<a href="#" style="font-size:12px;text-decoration: none;" onclick="displayDatePicker('dob', false, 'dmy', '/');">Select Date</a>
			</td>
		</tr>
		<tr>
			<td>Sex</td>
			<td>
				<form:select path="sex"  cssClass="element-select">
					<form:option value="" label=""/>
					<form:option value="M" label="Male"/>
					<form:option value="F" label="Female"/>
				</form:select>
			</td>
		</tr>
		<tr>
			<td>Course</td>
			<td><c:out value="${course.name}"/></td>
		</tr>
		<tr>
			<td>Batch</td>
			<td><c:out value="${course.batch}"/></td>
		</tr>
		<tr>
			<td>Course Semester<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td>
				<form:select path="subCourse"  cssClass="element-select">
					<form:option value="" label=""/>
					<form:options items="${semesters}" itemValue="idAsString" itemLabel="name"/>
				</form:select>
			</td>
		</tr>
		<tr>
			<td>Address</td>
			<td>
				<form:textarea path="address" cssClass="textarea"/>
			</td>
		</tr>
		<tr>
			<td>Phone no.</td>
			<td>
				<form:input path="phoneNo" cssClass="input-text"/>
			</td>
		</tr>
		<tr>
			<td>Email</td>
			<td>
				<form:input path="email" cssClass="input-text"/>
			</td>
		</tr>
	</c:if>
	<!-- Student Details Ends here -->
	
	<!-- Tutor / HOD Details Starts here -->
	<c:if test="${command.roleId == 'ROLE_HOD_FULL_ACCESS' || command.roleId == 'ROLE_HOD_VIEW_ONLY' || 
			command.roleId == 'ROLE_TUTOR_FULL_ACCESS' || command.roleId == 'ROLE_TUTOR_VIEW_ONLY'}">
		<tr>
			<td>Staff ID<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td>
				<form:input path="staffId" cssClass="input-text"/>
			</td>
		</tr>
		<tr>
			<td>Name<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td>
				<form:input path="name" cssClass="input-text"/>
			</td>
		</tr>
		<tr>
			<td>Department</td>
			<td><c:out value="${command.department.name}"/></td>			
		</tr>
		<tr>
			<td>Address</td>
			<td>
				<form:textarea path="address" cssClass="textarea"/>
			</td>
		</tr>
		<tr>
			<td>Phone no.</td>
			<td>
				<form:input path="phoneNo" cssClass="input-text"/>
			</td>
		</tr>
		<tr>
			<td>Email</td>
			<td>
				<form:input path="email" cssClass="input-text"/>
			</td>
		</tr>
	</c:if>
	<!-- Tutor / HOD Details Starts here -->
	
	<!-- Admin Details Starts here -->
	<c:if test="${command.roleId == 'ROLE_ADMIN_FULL_ACCESS' || command.roleId == 'ROLE_ADMIN_VIEW_ONLY'}">
		<tr>
			<td>Name<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td>
				<form:input path="name" cssClass="input-text"/>
			</td>
		</tr>
		<tr>
			<td>Address</td>
			<td>
				<form:textarea path="address" cssClass="textarea"/>
			</td>
		</tr>
		<tr>
			<td>Phone no.</td>
			<td>
				<form:input path="phoneNo" cssClass="input-text"/>
			</td>
		</tr>
		<tr>
			<td>Email</td>
			<td>
				<form:input path="email" cssClass="input-text"/>
			</td>
		</tr>
	</c:if>
	<!-- Admin Details Starts here -->
	
	</tbody>
</table>

<div class="subheader">Login Details:</div>

<table class="input-table">
	<tbody>
		<tr>
			<td width="20%"></td>
			<td>
				<form:checkbox path="updateLoginDetails" id="idUpdateLoginDetails" onclick="toggleLoginDetailSelection()"/>&nbsp; 
				Change password (Select to change the login password)
			</td>
		</tr>
		<tr>
			<td>Username</td>
			<td><c:out value="${command.username}"/></td>			
		</tr>
		<tr>
			<td>Password<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td>
				<c:choose>
					<c:when test="${command.updateLoginDetails eq false}">
						<form:input   path="newPassword"  id="idPassword"  cssClass="input-text" disabled="true"/>
					</c:when>
					<c:otherwise>
						<form:input path="newPassword"  id="idPassword"  cssClass="input-text" />
					</c:otherwise>
				</c:choose>					
			</td>
		</tr>
		<tr>
			<td>Retype Password<c:out value="${param.field_mandatory}" escapeXml="false"/></td>
			<td>
				<c:choose>
					<c:when test="${command.updateLoginDetails eq false}">
						<form:input path="retypePassword"  id="idRetypePassword"  cssClass="input-text" disabled="true"/>
					</c:when>
					<c:otherwise>
						<form:input path="retypePassword"  id="idRetypePassword"  cssClass="input-text" />
					</c:otherwise>
				</c:choose>					
			</td>
		</tr>
	</tbody>
</table>
		
<div class="bottom-btn">
	<input type="button" value="Save" name="action_btn_save" onclick="doSubmit('action_save')" <c:out value="${disableBtn} "/> />
	<input type="button" value="Cancel" name="action_btn_cancel" onclick="doSubmit('action_cancel')"/>
</div>
</form:form>